package cn.e4j.modular.api.controller;

import cn.e4j.core.dto.impl.Dto;
import cn.e4j.core.dto.requestDtoResolver.DtoParam;
import cn.e4j.core.dto.requestDtoResolver.DtoWapper;
import cn.e4j.core.reqres.response.ResponseData;
import cn.e4j.core.reqres.response.SuccessResponseData;
import cn.e4j.modular.api.service.WtjdService;
import cn.e4j.modular.api.service.WttdService;
import cn.e4j.modular.api.util.ControllerSupport;
import cn.e4j.modular.system.entity.SysUser;
import cn.e4j.modular.system.service.impl.SystemServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;

/**
 *  问题进度查询
 * @description
 * @datetime 2019-9-11 0011 17:10
 * @return
 */
@RestController
@RequestMapping("api/wtjd")
public class WtjdController extends ControllerSupport {

    @Autowired
    private WtjdService wtjdService;

    /**
     * 获取客户列表
     *
     * @return
     */
    @RequestMapping(value = "getEsaaList")
    public ResponseData getEsaaList(@DtoParam DtoWapper wapper) {
        Dto inDto = wapper.getDto();
        SysUser user = wapper.getSysUser();
        if(user.getTYPE() == "1"){//外部员工 获取归属客户和提单人员
            inDto.put("GWAA001", user.getACCOUNT());
            Dto gwaa = wtjdService.getGwaaData(inDto);
            if(!gwaa.equals(null)){
                inDto.put("ESAA001", gwaa.getString("GWAA010"));
                inDto.put("ESAB003", user.getID());
                Dto esab = wtjdService.getEsabData(inDto);
                if(esab.getBigDecimal("count").compareTo(new BigDecimal(0)) == 0){//当前登录用户不是主要联系人
                    inDto.put("ESAA002", user.getACCOUNT());
                }
            }
        }
        return new SuccessResponseData(wtjdService.getEsaaList(wapper.getPage(), inDto));
    }

}
